home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 1187 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.6 KB

  1. Path: engnews1.Eng.Sun.COM!taumet!clamage
  2. From: "Bradd W. Szonye" <bradds@ix.netcom.com>
  3. Newsgroups: comp.std.c++
  4. Subject: Why no standard classes to cope with times?
  5. Date: 21 Apr 1996 15:33:38 GMT
  6. Organization: Netcom
  7. Approved: clamage@eng.sun.com (comp.std.c++)
  8. Message-ID: <01bb2ee6.7fd76940$65c2b7c7@Zany.localhost>
  9. NNTP-Posting-Host: taumet.eng.sun.com
  10. X-Nntp-Posting-Host: det-mi3-05.ix.netcom.com
  11. X-Netcom-Date: Sat Apr 20  1:23:05 PM CDT 1996
  12. X-Newsreader: Microsoft Internet News
  13. Content-Length: 1698
  14. Originator: clamage@taumet
  15.  
  16. I have been perusing the DWP and have found nothing added to the Standard
  17. C Library for coping with times, in particular a method for computing a
  18. new time by adding an offset to a known time or finding the difference
  19. between two times.
  20.  
  21. The standard mktime() almost does this well already. The fact that a
  22. "suitable" method already exists is probably why nothing was added to the
  23. standard. However, string<> was added to standardize the many differing
  24. implementations of strings. Lots of vendors provide a custom date/time
  25. object too; why were these classes not also standardized?
  26.  
  27. The particular problem I run into has to do with daylight savings time. In
  28. places where DST is an issue, there's typically one day of the year that
  29. has two ranges of time from 1am to 2am and another day of the year where
  30. that time range doesn't exist. The standard doesn't seem to address this
  31. issue well. Suppose I use mktime() to create "The first Sunday in April at
  32. 1:30am"? Where I live, that time doesn't exist. What does mktime() create?
  33. Or "The first Sunday in November at 1:30am"? Where I live, there are two
  34. possible interpretations of that.
  35.  
  36. Even worse, suppose I have a struct tm containing "The day before daylight
  37. savings time begins at 12pm." When I add 24 hours to tm_hours and set
  38. tm_isdst to -1, what does mktime() create? The next day at 12pm, 1pm, or
  39. 11am? Daylight savings time or not? Which semantics I want probably
  40. depends on whether I'm trying to calculate "1 day from now" or "24 hours
  41. from now."
  42.  
  43. There has to be some reasonable answer to these questions; why doesn't the
  44. standard address it? Or am I just missing something?
  45.  
  46. --
  47. Bradd W. Szonye
  48. Doubleplus Corporation
  49. bradds@ix.netcom.com
  50.  
  51.  
  52.  
  53. [ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
  54. [ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
  55. [ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
  56. [ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
  57. [ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]
  58.